package com.atguigu.realtime.publisher.trade.mapper;

import com.atguigu.realtime.publisher.trade.bean.TradeProvinceOrderBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface TradeProvinceMapper {
    // 查看 各省份 的订单数 和 订单金额

    @Select(
            "select\n" +
                    "    province_name,sum(order_count) orderCount,ROUND(sum(order_amount)/1000, 4) orderAmount\n" +
                    " from gmall2024_realtime.dws_trade_province_order_window\n" +
                    " partition (par${date})\n" +
                    " group by province_name;"
    )
    List<TradeProvinceOrderBean> selectProvinceOrder(@Param("date") String date);


    // 查看 总额

    @Select(
            "select\n" +
                    "    sum(order_amount)\n" +
                    " from gmall2024_realtime.dws_trade_province_order_window\n" +
                    " partition (par${date});"
    )
    BigDecimal selectTotalAmount(@Param("date") String date);

}
